import java.util.Arrays;

public class ArrayPairSum {

    public int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int i = nums.length - 2;
        int ans = 0;
        while (i >= 0) {
            ans += nums[i];
            i -= 2;
        }
        return ans;
    }
}
